/**
 * @description 用户信息增删改查 api 路由
 * @author LI
 */

const router = require('koa-router')()
const {
  getUserAll,
  deleteUser
} = require('../../controller/userAdmin')

router.prefix('/jihuide/userAdmin')

// 查询所有用户信息
router.post('/getUserAll', async (ctx, next) => {
  const { userName, page, limit } = ctx.request.body
  // 接下来交给控制层
  ctx.body = await getUserAll({
    userName,
    page,
    limit,
  })
})

// 删除账号
router.post('/deleteUser', async (ctx, next) => {
  let { id } = ctx.request.body
  id = parseInt(id)
  // 接下来交给控制层
  ctx.body = await deleteUser(id)
})

module.exports = router
